#![feature(inherent_associated_types)]

pub struct CAddonMem {
    bar:MBox<Bar>
}

impl BarInc for CAddonMem {
    fn inc(&mut self,s :usize) -> usize {self.bar.inc(s)}
}

impl Headed for CAddonMem {
    type ehead = Bar;
}

impl Addons for CAddonMem {
    fn init<T:Headed>(cpb: &CPBlock<T>) -> Result<CAddonMem> {
        let bar = cpb.head.as_subtype::<Bar>(ADDONPOST)?; 
        Ok(CAddonMem{bar:bar}) 
    }
}

impl fmt::Display for Addon<CAddonMem> { 
    fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
        write!(f,"cmem {} bar:{}",self.block,self.addon.bar.pos)
    }
}
pub type CMem = Addon<CAddonMem>;